This is the replication package for:

Daniel Pemstein, Stephen A. Meserve and William T. Bernhard.
"Brussels Bound: Policy Experience and Candidate
Selection in European Elections."  Comparative Political Studies.

This package includes the following files:

README              - This file.
nomep_0.1.tar.gz    - A source-based R package for fitting the ranking
		      model described in the manuscript.  This is a
		      bare-bones piece of software and is not documented.
		      Please contact the authors if you need help installing
		      or using the package.
data/activity.dta   - EP 7th session activity counts for table and figure 1.
data/candidates.dta - Raw candidate-level data.
data/parties.dta    - Raw party-level data.
src/activity.do     - Runs the MEP activity analysis included in section 2
		      of the paper.

src/candsum.do      - Generate candidate-level summary statistics in tables
		      2 and 3.
src/listsum.R       - Computes list-level descriptive statistics in the
		      appendix in table 5.
src/main-model.R    - Runs the regression analysis presented in the results
		      section of the paper.
src/main-pics.R     - Generate figures (and in-text stats) in results.
src/merge.R         - Merges the candidates and parties data.
src/select-model.R  - Runs the robustness check models included in the
src/open-model.R      supplemental materials.
src/open-int-model.R
src/partysum.do     - Party-level summary statistics in the supplemental
		      materials.
src/postpred-pics.R - Functions for creating posterior predicted plots
		      from ranking model fit.
src/reg-pic.R       - Functions for creating regression plots from ranking 
		      model fit.
XXX
src/robust-pics.R   - Generate the figures in the supplemental materials.
doc/codebook.txt    - Contains explanations of variables in the data files.
doc/EECS2009.pdf    - Codebook for the PIREDEU 2009 European Candidate Study.
doc/EEMS2009.pdf    - Codebook for the PIREDEU 2009 European Manifesto Study.
doc/EESC2009.pdf    - Codebook for the PIREDEU 2009 EES Contextual Data.
fits/               - A directory where the model-fitting scripts save fitted
		      models.  Ships empty.


To replicate the analysis (note that file system paths in scripts
follow unix conventions, you may need to switch the slashes from
forward to back on windows machines):

1. To replicate the MEP activity analysis in section 2 of the paper,
specifically table 1, figure 1, and the statistical tests reported in
the text, open stata and set your working directory to the src folder
within this package.  Then,

> do "activity.do"

2. To replicate the candidate-level summary statistics in tables 2 and
3 of the manuscript, open stata and set your working directory to the
src directory within this pakage.  Then,

> do "candsum.do"

3. Install the nomep R library included in this replication package.
The authors have tested this library on our own Linux, OS X and
Windows machines, but we cannot guarantee that it will work on your
platform.  While we are happy to field questions about using this
software (contact Dan Pemstein at daniel.pemstein@ndsu.edu), please
consult the extensive R documentation on installing packages and/or
your local sysadmin before asking the authors for help with installing
the package on your system.  We simply cannot replicate every possible
install target, nor are we able to devote substantial time to
diagnosing the peculiarities of your system.  This is not production
quality software and we cannot formally support it; use at your own
risk.

4. Once nomep is installed, start up an R session and set your working
directory to the src folder in this package (replace PATHTOPACKAGE as
appropriate on your system).  All the steps below assume you are
running an R session in this working directory.

> setwd("PATHTOPACKAGE/src")

5. Merge the candidate and party datasets by typing
  
>  source("merge.R")

6. Fit the main model presented in the result section of the paper

> source("main-model.R", echo=T)

Note that this will take quite some time (probably upwards of 24
hours, even on a very fast 4+ core machine by 2015 standards).
You can shorten the sample run time by setting the MCMC and BURNIN
variables in src/main-model.R (adjust THIN appropriately to get the
number of sample draws that you want), although chains may not
converge sufficiently if you reduce the number of samples drawn.  We
have had trouble running the model fitting code from within RStudio.
Rather, one should use a vanilla R session.

Note that while we set fixed RNG seeds for the MCMC sampler we
neglected to set a seed for the beta starting values that are drawn in
R and passed to the C++ code, and did not store the starting values we
used when fitting the model for the paper, thus any given run of the
model will produce slightly different values from what we report in
the paper.  These differences should be negligible, but,
unfortunately, preclude perfect reproduction of the manuscript
results.

7. Generate the figures and statistics/comparisons reported in the
text of the results section:

source("main-pics.R", echo=T)

8. Generate the list-level summary statistics provided in the appendix:

> source("listsum.R", echo=T)

9. Fit the robustness models in the appendix.  These also take some time:

> source("select-model.R")
> source("open-model.R")
> source("open-int-model.R")

10. Produce robustness model pics:

> source("robust-pics.R")